package com.yd.app.service.pc.statisticalService;

import com.yd.app.mapper.StatisticalMapper;
import com.yd.app.service.common.BaseService;
import com.yd.domain.business.Statistical;
import com.yd.domain.commom.PageModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 统计分析Service
 * Created by sunxianhui on 2018/3/15.
 */
@Service
public class StatisticalService extends BaseService {
    @Autowired
    private StatisticalMapper statisticalMapper;
    /**
     * 根据产品类型分页查询
     * @param statistical
     * @param pageIndex
     * @param pageSize
     * @return
     */
    public PageModel getListByType(Statistical statistical, int pageIndex, int pageSize) {
        PageModel pm = new PageModel();
        int startRow = getStartRow(pageIndex, pageSize);
        List<Statistical> statisticalList = statisticalMapper.getListByType(statistical, startRow, pageSize);
        int count = 0;
        if (pageIndex == 1) {
            //查询总条数
            count = statisticalMapper.getCountByType(statistical);
            pm.setCount(count);
        }
        pm.setList(statisticalList);

        return pm;
    }

    /**
     * 根据客户类型分页查询
     * @param statistical
     * @param pageIndex
     * @param pageSize
     * @return
     */
    public PageModel getListByUser(Statistical statistical, int pageIndex, int pageSize) {
        PageModel pm = new PageModel();
        int startRow = getStartRow(pageIndex, pageSize);
        List<Statistical> statisticalList = statisticalMapper.getListByUser(statistical, startRow, pageSize);
        int count = 0;
        if (pageIndex == 1) {
            //查询总条数
            count = statisticalMapper.getCountByUser(statistical);
            pm.setCount(count);
        }
        pm.setList(statisticalList);

        return pm;
    }
}